CC=g++
CFLAGS=-O2 -Wall -std=c++0x -funroll-loops -c
LDFLAGS=-O2 -lm
BASEDIR=$(shell readlink -f .)
OBJDIR=${BASEDIR}/obj/
SRCDIR=${BASEDIR}/src/
INCLUDEDIRS=${BASEDIR}/include/
SRCLIST=$(shell ls ${SRCDIR})
SOURCES=$(addprefix ${SRCDIR}, ${SRCLIST})
INCLUDES=$(addprefix -I, ${INCLUDEDIRS})
EXECUTABLE=MyBot

#Uncomment the following to enable debugging
#CFLAGS+=-g -DDEBUG

all: compile linking

compile:
	@echo Compile [${SRCLIST}]
	@mkdir -p ${OBJDIR}
	@cd ${OBJDIR};\
	$(CC) ${CFLAGS} ${INCLUDES} ${SOURCES};\
	cd ..

linking: compile
	@echo Link [$(shell ls ${OBJDIR})]
	@${CC} ${LDFLAGS} $(addprefix ${OBJDIR}, $(shell ls ${OBJDIR})) -o ${EXECUTABLE}
 

clean:
	@rm -rf ${OBJDIR} 
	@rm -f ${EXECUTABLE}


.PHONY: all clean compile linking

